package com.shihb.akka.actors

import java.util.concurrent.TimeUnit

import akka.actor.{Actor, ActorRef}

/**
 * Description:
 *
 * @author shihb
 * @date 2020/10/2 20:28
 *
 */
class AActor(val ref: ActorRef) extends Actor {

  override def receive: Receive = {
    case "start" => {
      println("AActor 出招了,start OK")
      self ! "我打" //发给自己
    }
    case "我打" => {
      // 给其他Actor发消息,需要持有其他Actor的引用
      val msg = "AActor(黄飞鸿) 厉害 看我佛山无影脚"
      println(msg)
      TimeUnit.SECONDS.sleep(2)
      ref ! "开打"
    }
  }
}
